<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hello</title>
    <!-- 导入vue包 -->
    <script src="./lib/vue2.6.10.js"></script>
    <script src="./lib/vue-router.js"></script>
</head>
<body>
    <div id="app">
        <router-link to="/login?id=1231">登录</router-link> |
        <router-link to="/reg/2019">注册</router-link> 
        <router-view></router-view>
    </div>

    <script>

        var login = {
            template: "<h1>登录组件</h1>",
            created() {
                console.log(this.$route);
            },
        };
        var reg = {
            template: "<h1>注册组件</h1>",
            created() {
                console.log(this.$route);
                
            },
        };
        var router = new VueRouter({
            routes : [
                {path: '/', redircet: '/login'},
                {path: '/login', component: login},
                {path: '/reg/:t', component: reg},
            ]
        })
        // 创建一个vue实例
        var vm = new Vue({
            el:'#app', // 当前new的这个vue实例要控制的DOM
            data:{     // 所有的数据
            },
            router
        })

    </script>
</body>
</html>